import 'package:flutter_cate/core/model/meal_model.dart';
import 'package:flutter/material.dart';
import 'package:flutter_cate/core/viewmodel/base_view_model.dart';

class AMFavorViewModel extends BaseMealViewModel {
  // List<AMMealModel> _favorMeals = [];
  // List<AMMealModel> get favorMeals {
  //   return _favorMeals;
  // }

  void addMeal(AMMealModel meal) {
    originMeals.add(meal);
    notifyListeners();
  }

  void removeMeal(AMMealModel meal) {
    originMeals.remove(meal);
    notifyListeners();
  }

  void handleMeal(AMMealModel meal) {
    if (isFavor(meal)) {
      removeMeal(meal);
    } else {
      addMeal(meal);
    }
  }

  bool isFavor(AMMealModel meal) {
    return originMeals.contains(meal);
  }
}